package com.pxr.tutorial.xmltest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;


public class CopyFunctions {
	
	public CopyFunctions(){
		
	}
	public boolean copyFile(String filename, String addSrc) throws Exception {
		BufferedReader in = null;
		 try {
		  HttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet();
          request.setURI(new URI("http://1.1.1.1/"+filename+"&"+addSrc));
          HttpResponse response = client.execute(request);
          in = new BufferedReader
          (new InputStreamReader(response.getEntity().getContent()));
          StringBuffer sb = new StringBuffer("");
          String line = "";
          String NL = System.getProperty("line.separator");
          while ((line = in.readLine()) != null) {
              sb.append(line + NL);
          }
          in.close();
          String page = sb.toString();
          System.out.println(page);
          } finally {
		if (in != null) {
              try {
                  in.close();
                  return false;
                  } catch (IOException e) {
                  e.printStackTrace();
              }
          }
		}
		return true;
	}
}

